﻿using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Toon.Models.Characters;
using Granite.Axml;

namespace Toon.Views
{
	[Activity(Label = "Toon", Icon = "@drawable/icon")]
	public class MainView : NavigationActivity<PrimaryViewModel>
	{

		protected override void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);
		}

		void MyButton_Click(object sender, EventArgs e)
		{
			//var layoutRoot = FindViewById<LinearLayout>(Resource.Id.LayoutRoot);
			//var textView = new TextView(this);
			//textView.Text = "Boom!";
			//layoutRoot.AddView(textView);

			ViewModel.OpenToonWebsite();
		}

		void StartButton_OnClick(object sender, EventArgs e)
		{
			System.Diagnostics.Debug.WriteLine("Hi!");

			//var rules = new StandardRules(new Toon.Models.Catalogs.StandardCatalog());
			//var character = rules.CreateRandomCharacter();
			//System.Diagnostics.Debug.WriteLine(character.Species);

			base.StartActivity(new Intent(this, typeof(HomeView)));
		}

		protected override void OnResume()
		{
			base.OnResume();
			
			// Set our view from the "main" layout resource
			SetContentView(Resource.Layout.Main);

			// Get our button from the layout resource,
			// and attach an event to it
			var StartButton = FindViewById<Button>(Resource.Id.StartButton);
			StartButton.Click += StartButton_OnClick;

			var MyButton = FindViewById<Button>(Resource.Id.MyButton);
			MyButton.Click += MyButton_Click;
			

			var layoutRoot = FindViewById<LinearLayout>(Resource.Id.LayoutRoot);
			var textView = new TextView(this);
			textView.Text = "Resumed";
			layoutRoot.AddView(textView);
		}

		protected override void OnPause()
		{
			base.OnPause();

			var layoutRoot = FindViewById<LinearLayout>(Resource.Id.LayoutRoot);
			var textView = new TextView(this);
			textView.Text = "Paused";
			layoutRoot.AddView(textView);
		}
	}
}


